Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
"DiscordAPIError: Cannot send an empty message"

I am trying to make a profanity discord bot. Whenever I run it, it is fine but when I type a word that it's supposed to filter out, it stops. This is the error I get when typing in a blocked word.

DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\loser\Desktop\word filter bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\loser\Desktop\word filter bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async TextChannel.send (C:\Users\loser\Desktop\word filter bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15)
at async Client.<anonymous> (C:\Users\loser\Desktop\word filter bot\index.js:33:19) {
method: 'post',
path: '/channels/954840804466257921/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
  content: undefined,
  tts: false,
  nonce: undefined,
  embeds: undefined,
  components: undefined,
  username: undefined,
  avatar_url: undefined,
  allowed_mentions: undefined,
  flags: undefined,
  message_reference: undefined,
  attachments: undefined,
  sticker_ids: undefined
  },
  files: []
  }
  }

and here is my code

const Discord = require('discord.js');
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
const prefix = '-'

client.once('ready', () => {
console.log('woohoo, Im ready to get online and block some words!')
client.user.setActivity('-help', {type: 'LISTENING'})
})

client.on('message', async message => {
if(message.channel.type === 'dm' || message.author.bot) return;

const logChannel = client.channels.cache.find(channel => channel.id === '954845946326450206')
let words = ["banana", "orange"]

let foundInText = false;
for (var i in words) {
    if (message.content.toLowerCase().includes(words[i].toLowerCase())) foundInText = true;
}

if (foundInText) {
    let logEmbed = new Discord.MessageEmbed()
    .setDescription(`<@${message.author.id}> Said a bad word`)
    .addField('The Message', message.content)
    .setColor('RANDOM')
    .setTimestamp()
    logChannel.send(logEmbed)

    let embed = new Discord.MessageEmbed()
    .setDescription(`That word is not allowed here`)
    .setColor('RANDOM')
    .setTimestamp()
    let msg = await message.channel.send(embed);
    message.delete()
    msg.delete({timeout: '3500'})
}
})

is there anyway you guys can help me out? I would really like to get this up and running.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I assume you're using discord.js v13.

The send method only take one parameter since v13. You can to use send({ embeds: [your, cool, embeds] }); to send embeds or any message that contain not only contents.

Also the Message.prototype.delete() does not take any parameter now. You have to use setTimeout if you want to delete messages after a certain amount of time.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda